package com.starsea.book.ui.newpage.weidget.banner.transformer

import android.view.View
import androidx.core.view.ViewCompat

/**
 * 描述:
 */
class ZoomStackPageTransformer : BannerPageTransformer() {
  override fun handleInvisiblePage(view: View, position: Float) {}
  override fun handleLeftPage(view: View, position: Float) {
    ViewCompat.setTranslationX(view, -view.width * position)
    ViewCompat.setPivotX(view, view.width * 0.5f)
    ViewCompat.setPivotY(view, view.height * 0.5f)
    ViewCompat.setScaleX(view, 1 + position)
    ViewCompat.setScaleY(view, 1 + position)
    if (position < -0.95f) {
      ViewCompat.setAlpha(view, 0f)
    } else {
      ViewCompat.setAlpha(view, 1f)
    }
  }

  override fun handleRightPage(view: View, position: Float) {
    ViewCompat.setTranslationX(view, -view.width * position)
    ViewCompat.setPivotX(view, view.width * 0.5f)
    ViewCompat.setPivotY(view, view.height * 0.5f)
    ViewCompat.setScaleX(view, 1 + position)
    ViewCompat.setScaleY(view, 1 + position)
    if (position > 0.95f) {
      ViewCompat.setAlpha(view, 0f)
    } else {
      ViewCompat.setAlpha(view, 1f)
    }
  }
}